define(['jquery', 'bootstrap', 'utilback', 'table', 'form', 'myfileinput','zh','ztree'], function ($, undefined, Utilback, Table, Form,myfileInput,zh) {

    var Controller = {
    	config: {
    		get_url: '/user/read/detail', // 获取用户详情
    	},
        init: function () {
            // 初始化表格参数配置
            Table.api.init({
            	singleSelect: true,
                extend: {
                    index_url: './json/videoManage.json', // 查询列表
                    add_url: 'videoManageAdd.html', // 新增页面
                    edit_url: 'videoManageAdd.html', // 修改页面
                    del_url: '/videoManage', // 删除
                    multi_url: '/videoManage',
                }
            });
            var table = $("#userTable");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                method:'get',
                singleSelect:true,
                showExport:false,
                showToggle: false,
                columns: [
                    [
                        {field: 'state', checkbox: true, },
                        {field: 'id', title: 'ID'},
                        {field: 'name', title: '名称'},
                        {field: 'content', title: "内容"},
                        {field: 'accessory', title: "附件"},
                        {field: 'remark', title: "备注"},
                        {field: 'uploadTime', title: "上传时间"},
                        {field: 'uploadMan', title: "上传人"},
                        {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: function (value, row, index) {
                                if(row.userType == 3) {
                                    return '';
                                }
                                return Table.api.formatter.operate.call(this, value, row, index, table);
                            }}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
           },

        edit: function () { // 初始化编辑页面
            Form.api.bindevent($("form[role=form]"));
            Form.api.fill($("form[role=form]"),'./json/videoManage.json',1);
            Util.api.initSelectTree({
                checkParent: true,
                parentEle: 'department',
                url: './json/list.json',
                data: JSON.stringify({keyword:''}),
                resetData: function(data) {
                   for(var i=0;i<data.length;i++) {
                       if(data[i].leaf == 0) {
                           data[i]['open'] = true;
                       }
                       data[i]['pId'] = data[i].parentId;
                       data[i]['name'] = data[i].deptName;
                   }
                   return data;
                }
            });
            var id = Util.api.query('id');
            var t = Util.api.query('t');
            if(id && t === 'U') {
                Form.api.fill($('#edit-form'), Controller.config.get_url, id, function(data) {
                });
            }
              $(".excelFile").fileinput({
                           uploadUrl: "/FileUpload/Upload",//上传的地址
                            msgPlaceholder:'请音视频附件',
                            uploadAsync: true,              //异步上传
                            language: 'zh',                 //设置语言
                            showCaption: true,              //是否显示标题
                            showUpload: true,               //是否显示上传按钮
                            showRemove: true,               //是否显示移除按钮
                            showPreview : true,             //是否显示预览按钮
                            browseClass: "btn btn-primary", //按钮样式 
                            dropZoneEnabled: false,         //是否显示拖拽区域
                            allowedFileExtensions: [], //接收的文件后缀
                            maxFileCount: 10,                        //最大上传文件数限制
                            previewFileIcon: '<i class="glyphicon glyphicon-file"></i>',
                            allowedPreviewTypes: null,
                            previewFileIconSettings: {
                                'docx':'<i class="glyphicon glyphicon-file"></i>',
                                'xlsx':'<i class="fa fa-file-o"></i>',
                                'pptx': '<i class="glyphicon glyphicon-file"></i>',
                                'jpg': '<i class="glyphicon glyphicon-picture"></i>',
                                'pdf': '<i class="glyphicon glyphicon-file"></i>',
                                'zip': '<i class="fa fa-file-o"></i>',
                            },
                            uploadExtraData: {  //上传的时候，增加的附加参数
                                folder: '数据导入文件', guid: $("#AttachGUID").val()
                            }
                        })
        },
        update: function() {
            Form.api.bindevent($("form[role=form]"));
        	Util.api.ajax({
        		type: 'GET',
        		// url: '/user/read/current'
                url:'',
        	}, function(data) {
        		$('#edit-form').autofill(data);
        	});
        }
    };
    return Controller;
      function changeAgentContent(){
            document.getElementById("inputFileAgent").value
     = document.getElementById("inputFile").value;
    }
  
});